package xworker.javafx.control;

import javafx.scene.control.Label;
import org.xmeta.ActionContext;
import org.xmeta.Thing;
import xworker.javafx.beans.property.PropertyFactory;

public class LabelActions {
	static{
		PropertyFactory.regist(Label.class, "labelForProperty", o -> {
			Label obj = (Label) o;
			return obj.labelForProperty();
		});
	}

	public static void init(Label label, Thing thing, ActionContext actionContext) {
		LabeledActions.init(label, thing, actionContext);
	}

	public static Label create(ActionContext actionContext) {
		Thing self = actionContext.getObject("self");
		
		Label item = new Label();
		init(item, self, actionContext);

		actionContext.g().put(self.getMetadata().getName(), item);
		
		actionContext.peek().put("parent", item);
		for(Thing child : self.getChilds()) {
			child.doAction("create", actionContext);
		}
		
		return item;
	}
}
